package com.wing.warehouse.controller.admin.service;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.warehouse.dao.WarehouseFactoryAreaDao;
import com.wing.warehouse.model.entity.WarehouseFactoryAreaEntity;
import com.wing.warehouse.model.entity.WarehouseFactoryAreaVO;
import com.wing.warehouse.model.request.WarehouseFactoryAreaForm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 仓库库区-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class WarehouseFactoryAreaServiceImpl extends ServiceImpl<WarehouseFactoryAreaDao, WarehouseFactoryAreaEntity> implements WarehouseFactoryAreaService {

    @Override
    public int add(WarehouseFactoryAreaForm warehouseAreaForm) {
        //校验
        WarehouseFactoryAreaEntity warehouseArea =new WarehouseFactoryAreaEntity();
        CopyOptions copyOptions = CopyOptions.create()
                .setEditable(WarehouseFactoryAreaEntity.class)
                .setIgnoreError(true)
                .setIgnoreNullValue(true);
        BeanUtil.copyProperties(warehouseAreaForm, warehouseArea, copyOptions);
        return baseMapper.insert(warehouseArea);
    }

    @Override
    public List<WarehouseFactoryAreaVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<WarehouseFactoryAreaVO> pageList4app(Page page, Map<String, Object> params) {
        List<WarehouseFactoryAreaVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public WarehouseFactoryAreaVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }
}
